<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.fick.hibernate.model.Admin"%>
<%@page import="com.fick.hibernate.dao.SysMenuDAO"%>
<%@page import="com.fick.hibernate.dao.RoleMenuDAO"%>
<%@page import="com.fick.hibernate.model.SysMenu"%>
<%@page import="com.fick.hibernate.model.RoleMenu"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
Admin admin = (Admin) request.getSession().getAttribute("admin");
%>

<head>
<title></title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function showMenu(sid)
	{
	   
	   var temp = eval("submenu"+sid);
	   if(temp.style.display == "none")
	   {
	      eval("submenu"+sid+".style.display=\"\";");
	   }
	   else
	   {
	      eval("submenu"+sid+".style.display=\"none\";");
	   }
	}
	</script>
</head>
<body>
<table width="193" height="" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="top" background="images/left_bj.gif"><table width="193" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="78" align="center" valign="middle" background="images/admin_bj.gif"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="80" height="60" align="center" valign="middle"><img src="images/touxiang.gif" width="60" height="60"></td>
            <td width="120" height="60" align="left" valign="middle"><table width="120" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="24" align="center" valign="middle">您好，欢迎您<br/>
                <%=admin.getRole().getRoleName() %>
				</td>
              </tr>
              <tr>
                <td height="24" align="center" valign="middle" class="hy_mz"><%=admin.getAdminName()%></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table>    
      <table width="186" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="26" align="center" valign="middle" background="images/menu_t.gif" class="xt_mz">系统功能</td>
        </tr>
      </table>      
		    <table width="180" border="0" cellspacing="0" cellpadding="0">
             
			 <%
			 SysMenuDAO menuDAO=new SysMenuDAO();
			 RoleMenuDAO roleMenuDAO=new RoleMenuDAO();
			 SysMenu menu;
			 RoleMenu roleMenu;
			//fick707superadmin为最高管理员，显示所有
			if(admin.getAdminName().equals("fick707superadmin")){
				 //提取一级菜单
				List list=menuDAO.findBySql(SysMenu.class,"where parId is null order by menuOrder");
				List list2;
				if(list!=null && list.size()>0){
					for(int i=0;i<list.size();i++){
						menu=(SysMenu)list.get(i);
						%>
						<tr>
                <td height="25" align="center" valign="middle" background="images/left_xbj2.gif">
				<table width="170" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                    <td width="20" height="25" align="center" valign="middle">
					<img src="images/left_dot3.gif" width="3" height="6">
					</td>
					<td height="25" align="left" valign="middle" class="hy_dhwz" onClick="showMenu(<%=i %>)">
					<a href="#"><%=menu.getMenuName() %></a>
					</td>
                  </tr>
				  <tr>
						<td align="left" id="submenu<%=i %>"  style="display:none" colspan="2">
				  			<div id="mode0">
								 <table width="180" border="0" cellspacing="0" cellpadding="0">
									<%
									//二级菜单
									list2=menuDAO.findBySql(SysMenu.class,"where parId="+menu.getId()+" order by menuOrder");
									if(list2!=null && list2.size()>0){
										for(int j=0;j<list2.size();j++){
										menu=(SysMenu)list2.get(j);
									%>
									
									<tr>
									  <td width="30" height="25" align="center" valign="middle" background="images/left_xbj1.gif"><img src="images/left_dot1.gif" width="12" height="12">
									  </td>
									  <td height="25" align="left" valign="middle" background="images/left_xbj1.gif" class="hy_dq">
									  <a href="<%=menu.getMenuUrl() %>" target="mainFrame"><%=menu.getMenuName() %></a>
									  </td>
									</tr>	
			  						<%}} %>
								
								</table>
					  		</div>	
						</td>
				  </tr>
                </table>
				</td>
              </tr>
						<%
					}
				}
			}else{
				//提取一级菜单
				List list=roleMenuDAO.findBySql(RoleMenu.class,"where menuId.parId is null and roleId.id="+admin.getRole().getId()+" and menuId.menuShow=1 order by menuId.menuOrder");
				List list2;
				if(list!=null && list.size()>0){
					for(int i=0;i<list.size();i++){
						roleMenu=(RoleMenu)list.get(i);
						menu=roleMenu.getMenuId();
						%>
						<tr>
                <td height="25" align="center" valign="middle" background="images/left_xbj2.gif">
				<table width="170" border="0" cellspacing="0" cellpadding="0">
                 <tr>
                    <td width="20" height="25" align="center" valign="middle">
					<img src="images/left_dot3.gif" width="3" height="6">
					</td>
					<td height="25" align="left" valign="middle" class="hy_dhwz" onClick="showMenu(<%=i %>)">
					<a href="#"><%=menu.getMenuName() %></a>
					</td>
                  </tr>
				  <tr>
						<td align="left" id="submenu<%=i %>"  style="display:none" colspan="2">
				  			<div id="mode0">
								 <table width="180" border="0" cellspacing="0" cellpadding="0">
									<%
									//二级菜单
									list2=roleMenuDAO.findBySql(RoleMenu.class,"where menuId.parId="+menu.getId()+" and roleId.id="+admin.getRole().getId()+" and menuId.menuShow=1 order by menuId.menuOrder");
									if(list2!=null && list2.size()>0){
										for(int j=0;j<list2.size();j++){
										menu=((RoleMenu)list2.get(j)).getMenuId();
									%>
									
									<tr>
									  <td width="30" height="25" align="center" valign="middle" background="images/left_xbj1.gif"><img src="images/left_dot1.gif" width="12" height="12">
									  </td>
									  <td height="25" align="left" valign="middle" background="images/left_xbj1.gif" class="hy_dq">
									  <a href="<%=menu.getMenuUrl() %>" target="mainFrame"><%=menu.getMenuName() %></a>
									  </td>
									</tr>	
			  						<%}} %>
								
								</table>
					  		</div>	
						</td>
				  </tr>
                </table>
				</td>
              </tr>
						<%
					}
				}
			}
			 %>
			 
			  
			
            </table>
            <table width="180" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="65" align="center" valign="middle"><table width="160" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="24" align="left" valign="middle" class="hy_bq">
                  <br/>
                  版权所有<br/>
                 Fick Song
                  <br><br>
                  技术支持电话<br>
                  18516240550 </td>
                </tr>
                <tr>
                  <td height="24" align="left" valign="middle" class="hy_bq"></td>
                </tr>
              </table></td>
            </tr>
          </table>
          </td>
        </tr>
      </table>      
      <table width="186" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="3" background="images/menu_b.gif"></td>
        </tr>
      </table>
</body>
